package com.ssy.lingxi.member.merchant.model.bo;

import com.ssy.lingxi.member.merchant.entity.MemberDO;
import com.ssy.lingxi.member.merchant.entity.MemberUserDO;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.List;

/**
 * App - 用户登录后返回给前端页面的响应VO
 * @author 万宁
 * @version 2.0.0
 * @date 2020-12-05
 */
public class MobileLoginBO implements Serializable {
    private static final long serialVersionUID = 1261320334049466908L;

    public MobileLoginBO() {
    }

    public MobileLoginBO(Integer outerStatus, MemberDO memberDO, MemberUserDO userDO, Long roleId, Integer memberType, String token, Long tokenExpireMinutes, List<String> urls, List<MemberRoleItem> roles, List<UpperChannelItem> upperChannels) {
        this.outerStatus = outerStatus;
        this.userId = userDO.getId();
        this.memberId = memberDO.getId();
        this.memberRoleId = roleId;
        this.memberType = memberType;
        this.token = token;
        this.tokenExpireMinutes = tokenExpireMinutes;
        this.urls = urls;
        this.account = userDO.getAccount();
        this.company = memberDO.getName();
        this.name = userDO.getName();
        this.countryCode = userDO.getCountryCode();
        this.phone = userDO.getPhone();
        this.orgName = userDO.getOrg() == null ? "" : userDO.getOrg().getTitle();
        this.jobTitle = StringUtils.hasLength(userDO.getJobTitle()) ? userDO.getJobTitle() : "";
        this.idCardNo = userDO.getIdCardNo();
        this.mail = userDO.getEmail();
        this.logo = StringUtils.hasLength(userDO.getLogo()) ? userDO.getLogo() : "";
        this.userType = userDO.getTypeEnum();
        this.roles = roles;
        this.upperChannels = upperChannels;
    }

    /**
     * 平台审核状态，1-待提交审核，2-待平台审核，3-平台审核通过，4-平台审核不通过
     */
    private Integer outerStatus;

    /**
     * 用户id (前端进行缓存，在Http Headers中添加)
     */
    private Long userId;

    /**
     * 用户所属会员Id (前端进行缓存，在Http Headers中添加)
     */
    private Long memberId;

    /**
     * 用户当前的会员角色Id
     */
    private Long memberRoleId;

    /**
     * 会员类型：1-企业会员，2-企业个人会员，3-渠道会员，4-渠道个人会员
     */
    private Integer memberType;

    /**
     * 用户Token (前端进行缓存，在Http Headers中添加)
     */
    private String token;

    /**
     * Token过期时间（单位：分钟）
     */
    private Long tokenExpireMinutes;

    /**
     * 用户授权访问的前端页面菜单Code列表
     */
    private List<String> urls;

    /**
     * 用户账号
     */
    private String account;

    /**
     * 会员名称（公司名称）
     */
    private String company;

    /**
     * 用户姓名
     */
    private String name;

    /**
     * 国家代码（手机号码前缀，例如“+86”)
     */
    private String countryCode;

    /**
     * 手机号码
     */
    private String phone;

    /**
     * 所属组织机构
     */
    private String orgName;

    /**
     * 职位
     */
    private String jobTitle;

    /**
     * 身份证号
     */
    private String idCardNo;

    /**
     * 邮箱
     */
    private String mail;

    /**
     * 会员Logo Url
     */
    private String logo;

    /**
     * 用户类型， 1-会员超级管理员（主账号），0-会员创建的普通用户（子账号）
     */
    private Integer userType;

    /**
     * 会员角色列表
     */
    private List<MemberRoleItem> roles;

    /**
     * 上级渠道会员列表
     */
    private List<UpperChannelItem> upperChannels;

    public static class MemberRoleItem implements Serializable{
        private static final long serialVersionUID = 6318747746358880289L;

        public MemberRoleItem() {
        }

        public MemberRoleItem(Long roleId, String roleName, Integer roleType) {
            this.roleId = roleId;
            this.roleName = roleName;
            this.roleType = roleType;
        }

        /**
         * 会员角色Id
         */
        private Long roleId;

        /**
         * 会员角色名称
         */
        private String roleName;

        /**
         * 会员角色类型，1-服务提供者，2-服务消费者
         */
        private Integer roleType;

        public Long getRoleId() {
            return roleId;
        }

        public void setRoleId(Long roleId) {
            this.roleId = roleId;
        }

        public String getRoleName() {
            return roleName;
        }

        public void setRoleName(String roleName) {
            this.roleName = roleName;
        }

        public Integer getRoleType() {
            return roleType;
        }

        public void setRoleType(Integer roleType) {
            this.roleType = roleType;
        }
    }

    public static class UpperChannelItem implements Serializable{
        private static final long serialVersionUID = -8408216798677850634L;

        public UpperChannelItem() {
        }

        public UpperChannelItem(Long upperMemberId, Long upperRoleId, String name) {
            this.upperMemberId = upperMemberId;
            this.upperRoleId = upperRoleId;
            this.name = name;
        }

        /**
         * 上级渠道会员Id
         */
        private Long upperMemberId;

        /**
         * 上级渠道会员角色Id
         */
        private Long upperRoleId;

        /**
         * 上级渠道会员名称
         */
        private String name;

        public Long getUpperMemberId() {
            return upperMemberId;
        }

        public void setUpperMemberId(Long upperMemberId) {
            this.upperMemberId = upperMemberId;
        }

        public Long getUpperRoleId() {
            return upperRoleId;
        }

        public void setUpperRoleId(Long upperRoleId) {
            this.upperRoleId = upperRoleId;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    public Integer getOuterStatus() {
        return outerStatus;
    }

    public void setOuterStatus(Integer outerStatus) {
        this.outerStatus = outerStatus;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getMemberRoleId() {
        return memberRoleId;
    }

    public void setMemberRoleId(Long memberRoleId) {
        this.memberRoleId = memberRoleId;
    }

    public Integer getMemberType() {
        return memberType;
    }

    public void setMemberType(Integer memberType) {
        this.memberType = memberType;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Long getTokenExpireMinutes() {
        return tokenExpireMinutes;
    }

    public void setTokenExpireMinutes(Long tokenExpireMinutes) {
        this.tokenExpireMinutes = tokenExpireMinutes;
    }

    public List<String> getUrls() {
        return urls;
    }

    public void setUrls(List<String> urls) {
        this.urls = urls;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCountryCode() {
        return countryCode;
    }

    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }

    public String getJobTitle() {
        return jobTitle;
    }

    public void setJobTitle(String jobTitle) {
        this.jobTitle = jobTitle;
    }

    public String getIdCardNo() {
        return idCardNo;
    }

    public void setIdCardNo(String idCardNo) {
        this.idCardNo = idCardNo;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }

    public List<MemberRoleItem> getRoles() {
        return roles;
    }

    public void setRoles(List<MemberRoleItem> roles) {
        this.roles = roles;
    }

    public List<UpperChannelItem> getUpperChannels() {
        return upperChannels;
    }

    public void setUpperChannels(List<UpperChannelItem> upperChannels) {
        this.upperChannels = upperChannels;
    }
}
